const url = 'http://www.csf12315.com';
module.exports = {
	// 请求域名
	network: url,

	// 图片裁剪、缩放的模式
	mixins: {
		data() {
			return {
				// 页面地址
				version: "1.0.1",
				network: url + "/h5/",
				networkIndistinguishable: url + "/h5",
				imageMode: "aspectFill",
				
			};
		},
		computed: {},
		created() {
			// 返回上一页触发  backPageFn
			uni.$on('getAddress', (data) => {
				if (this.backPageFn) this.backPageFn()
			})
		},
		async onPullDownRefresh() {
			if (this.reset) {
				this.reset('pageReset')
			}
			await this.init()
			uni.stopPullDownRefresh()
		},
		methods: {
			async initLogin() {
				const {
					data
				} = await this.$api.Usercenter()
				uni.setStorageSync('loginData', data);
			},
			back() {
				uni.navigateBack()
				uni.$emit('getAddress')
			},
			// 提示
			showToastMsg(msg, back = false) {
				uni.showToast({
					icon: "none",
					title: msg
				})
				if (back) {
					setTimeout(() => {
						uni.navigateBack()
					}, 1500)
				}
			},
			// 修改富文本
			imgAddStyle(str) {
				str+=''
				const regex1 = new RegExp("(i?)(\<img)(?!(.*?style=['\"](.*)['\"])[^\>]+\>)", 'gmi')
				//匹配所有不含style="" 或 style='...'的img标签
				let value = str.replace(regex1, '$2 style=""$3')
				// 给不含style="" 或 style='' 的img标签加上style=""
				const regex2 = new RegExp("(i?)(\<img.*?style=['\"])([^\>]+\>)", 'gmi')
				value = value.replace(regex2, '$2max-width:100%;$3')
				return value;
			},
			// 检测是填写名片
			fillInBusinessCard(){
				const loginData = uni.getStorageSync('loginData');
				if (loginData && loginData.card_business_status == 0) {
					uni.navigateTo({
						url: '/pages/my/card/card',
					});
					return false;
				}
				return true;
			},
		},

	}
}